<?php

/***

LZRoster: A roster for World of Warcraft.
Copyright (C) 2007  Emmanuel Cron

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

***/

require_once "class/Load.class.php";
require_once "class/Config.class.php";
require_once "class/ListTable.class.php";
require_once "class/StatusRoster.class.php";
require_once "class/Localization.class.php";
require_once "class/SubscriptionManager.class.php";
require_once "class/SubscriptionDisplayer.class.php";

$load = Load::GetInstance();
$config = Config::GetInstance();
$localization = Localization::GetInstance();
$status_roster = StatusRoster::GetInstance();
$subscription_manager = SubscriptionManager::GetInstance();
$subscription_displayer = SubscriptionDisplayer::GetInstance();

$list_table = new ListTable($localization->Get('%s best uploaders', $subscription_manager->GetNbBestUploaders()), true);

foreach ($subscription_manager->GetBestUploaders() as $subscription)
{
	$list_table->AddLine(
		$subscription_displayer->Nickname($subscription),
		$subscription_displayer->TotalObjectsUpdated($subscription),
		"font-weight: bold;",
		$subscription_displayer->DetailObjectsUpdated($subscription)
	);
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
	<head>
		<title>LZRoster<?php echo $config->HasRosterTitle() ?  " - ".$config->GetRosterTitle() : null; ?></title>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<link rel="stylesheet" media="screen" type="text/css" href="styles/_.css" />
		<link rel="stylesheet" media="screen" type="text/css" href="styles/listtable.css" />
	</head>
	<body>
		
		<?php require_once "inc/head.php"; ?>
		<?php require_once "inc/hmenu.php"; ?>
		
		<h2><?php echo $localization->Get('home'); ?></h2>
		
		<?php
		if ($status_roster->HasMessage())
		{
		?>
			
			<p>
				<?php echo $localization->Get('this page produced some messages. please refer to the following lines'); ?>
			</p>
			
			<?php echo $status_roster->GetStack_InList(); ?>
			
			<p>
				<?php echo $localization->Get('you can refresh the page %s and try again', "index.php"); ?>
			</p>
			
		<?php
		}
		else
		{
		?>
		
		<p>
			<?php echo $localization->Get('welcome on the %s guilds roster from the %t server', implode(", ", $config->GetRosterGuilds()), $config->GetRosterServer()); ?>
		</p>
		<p>
			<?php echo $localization->Get('this website automatically saves the crafts (...)'); ?>
		</p>
		<p>
			<?php echo $localization->Get('you will be able to rapidly look at the character list (...)'); ?>
		</p>
		
		<?php echo $list_table->GetTable(); ?>
		
		<p style="text-align: center;">
			<?php echo $localization->Get('to use this tool, you must downlad an addon that you will find %s here', "addon.php"); ?><br />
			<?php echo $localization->Get('then, go on the %s send page', "send.php"); ?>
		</p>
		
		<p style="text-align: center;">
			<img src="img/wow-logo.jpg" alt="WoW Logo" />
		</p>
		
		<?php
		}
		?>
		
		<?php require_once "inc/foot.php"; ?>
		
	</body>
</html>